<?

$check_me_authed = "NO_OK";

if(($jid = $_POST["radioview"]) || ($jid = $_POST["job_id_posted"]) ){

	$Db = new oracleDb;
  $Db->init($_SESSION["ORCLU"],
            $_SESSION["OPASS"],
            $_SESSION["SID"],
            _NO_COMMENT);

	if ($Db->connect()) {

  	$srcDbHdr     = "USERID_HDR";
    $srcDbDtl     = "USERID_DTL";
    $srcDbAccess  = "USER_ACCESS";

		$_SESSION["jid"]  = $_POST["radioview"];
		$jobId            = &$_SESSION["jid"];

		$tmpBuf = explode(_DEFAULT_SEPARATOR_02,
	                    $jobId);

		$CLFetchers->fetchUsrHdr($Db,
		                         $tmpBuf[_USER_ID],
		                         $tmpBuf[_USER_COMPANY],
		                         $srcDbHdr,
		                         $nHdr,
		                         $resHdr);

		$CLFetchers->fetchUsrDtl($Db,
		                         $tmpBuf[_USER_ID],
		                         $tmpBuf[_USER_COMPANY],
		                         $srcDbDtl,
		                         $nDtl,
		                         $resDtl);

	  $CLFetchers->fetchLstAccess($Db,
                                $srcDbAccess,
                                $nAccess,
                                $lstAccess);

    $_POST["usrIdEnt"]    = $resHdr["USERID"][0];
    $_POST["usrNmEnt"]    = $resHdr["USERNAME"][0];
    $_POST["usrPwdEnt"]   = $resHdr["PASSWORD"][0];
    $_POST["usrCompEnt"]  = $resHdr["COMPANY"][0];
    $_POST["usrPosEnt"]   = $resHdr["POS"][0];
    $_POST["usrDeptEnt"]  = $resHdr["DEPARTMENT"][0];
    $_POST["usrStsEnt"]   = $resHdr["STATUS"][0];

	  for($iRow = 0; $iRow < $nAccess; $iRow++){

      for($iDtl = 0; $iDtl < $nDtl; $iDtl++){

        /**
         * if we have match then assigned the value
         * YES: copy detail
         * NO : default access
         */
        if($resDtl["LEVELMN"][$iDtl] == $lstAccess["LEVELMN"][$iRow]){

          $_POST["levelMnEnt"][$iRow]   = $resDtl["LEVELMN"][$iDtl];
          $_POST["descpEnt"][$iRow]     = $resDtl["DESCRIPTION"][$iDtl];
          $_POST["statusEnt"][$iRow]    = $resDtl["STATUS"][$iDtl];
          $_POST["entryEnt"][$iRow]     = $resDtl["ENTRY_RIGHTS"][$iDtl];
          $_POST["modifyEnt"][$iRow]    = $resDtl["EDIT_RIGHTS"][$iDtl];
          $_POST["deleteEnt"][$iRow]    = $resDtl["DELETE_RIGHTS"][$iDtl];
          $_POST["viewEnt"][$iRow]      = $resDtl["VIEW_RIGHTS"][$iDtl];
          $_POST["finalizeEnt"][$iRow]  = $resDtl["FINALIZE_RIGHTS"][$iDtl];
          $_POST["approvedEnt"][$iRow]  = $resDtl["APPROVED_RIGHTS"][$iDtl];
          $_POST["journalEnt"][$iRow]   = $resDtl["JOURNAL_RIGHTS"][$iDtl];
          $_POST["programsEnt"][$iRow]  = $resDtl["PROGRAMS"][$iDtl];
          $_POST["pictEnt"][$iRow]      = $resDtl["PICT"][$iDtl];
        }else{

          $_POST["levelMnEnt"][$iRow]   = $lstAccess["LEVELMN"][$iRow];
          $_POST["descpEnt"][$iRow]     = $lstAccess["DESCRIPTION"][$iRow];
        }
      }
    }

    $Db->dc();

    $_SESSION["modify_mode"] = "Y";

  	require("entry_restore_me.php");
	}else{

	  $Misc->usrDieJs(_DB_CONN_ERROR);
	}
}else{

	$Misc->usrDieJs("Error: No Selection");
}

?>